package chapter_eleven.text11_6demo6;

import java.util.ArrayList;

/**
 * Data time:2021/10/19 16:47
 * StudentID:2019112118
 * Author:hgw
 * Description:
 */
public class Container extends AbstractControler {
    public Container(String name) {
        this.name = name;
    }

    //定义集合Controller，用于存储AbstractControler类型的成员
    private ArrayList<AbstractControler> abstractList = new ArrayList<AbstractControler>();

    private String name;

    public void setName(String name) {
        this.name = name;
    }

    public void add(AbstractControler control) {
        abstractList.add(control);
    }

    public void remove(AbstractControler control) {
        abstractList.remove(control);
    }

    public AbstractControler getChild(int i) {
        return (AbstractControler)abstractList.get(i);
    }

    public void designControl() {
        //模拟设计控件
        System.out.println("*****对'" + name + "'容器下进行导出");//模拟设计一个容器

        //递归调用成员构建的designControl的方法
        for (Object object : abstractList) {
            ((AbstractControler)object).designControl();
        }
    }
}
